//
// Created by LiuYou on 2020/8/2.
//

#ifndef CLASSWITHCOMPOSITION_HARDDISK_H
#define CLASSWITHCOMPOSITION_HARDDISK_H


#include <ostream>

namespace ly {
    class HardDisk : public ClassInfo {
    private:
        int capacity;
    public:
        explicit HardDisk(int capacity = 0) : capacity(capacity) {}

        ~HardDisk() override = default;

        int getCapacity() const {
            return capacity;
        }

        void setCapacity(int capacity) {
            HardDisk::capacity = capacity;
        }

        friend std::ostream& operator<<(std::ostream& os, const HardDisk& disk) {
            os << "capacity: " << disk.capacity;
            return os;
        }

        std::string toString() override {
            return (std::string) "HardDisk{" +
                   "capacity=" + std::to_string(capacity) +
                   '}';
        }
    };

}


#endif //CLASSWITHCOMPOSITION_HARDDISK_H
